using System;
using System.Collections.Generic;
using System.Text;

namespace Publicuse.Entity
{
  /// <summary>
  /// 统一业务返回数据模型
  /// </summary>
  public class CommonResult
  {
    public string msg { get; set; }

    public int code { get; set; } = (int)CodeResult.success;

    public object data { get; set; }

    public object datab { get; set; }
    public object datac { get; set; }

    public long count { get; set; } = 0;

    public bool success
    {
      get { return string.IsNullOrEmpty(msg) ? true : false; }
    }

    public string timeconsuming { get; set; }

    public DateTime stTime { get; set; }

    public DateTime etTime { get; set; }

    public CommonResult()
    {
      this.msg = string.Empty;
      this.data = null;
      this.datab = null;
      this.stTime = DateTime.Now;
    }

    public string GetHS()
    {
      var sjc = (DateTime.Now - this.stTime);
      return $"耗时{sjc.Minutes}分钟{sjc.Seconds}秒{sjc.Milliseconds}毫秒;";
    }
  }

  /// <summary>
  /// 统一业务返回结果代码
  /// </summary>
  public enum CodeResult : int
  {
    dbconnect = 600,

    success = 200,

    export = 3000,

    fail = 300,

    exception = 400,

    nolegitimate = 401,

    logintimeout = 700,

    blacklist = 800
  }
}
